/*
 * $Author: kidbaw $
 * $Revision: 59 $
 * $Date: 2012-03-23 22:44:48 +0700 (Fri, 23 Mar 2012) $
 */

#import "SupportFunction.h"

#define TIMER_DISPLAY_TITLE_SCREEN                                          3.5
#define TIMER_MAIN_LOOP                                                     0.5
#define TIMER_COUNT_DOWN_UNIT                                               1
#define TIMER_MINUTE_PER_HOUR                                               60
#define TIMER_SEC_PER_MINUTE                                                60
#define TIMER_CHANGING_VIEW                                                 0.3
#define TIMER_KARDS_VIEW_CONTROLLER_CHECKING_FOR_TIP                        5
#define TIMER_KARDS_VIEW_CONTROLLER_HIDDING_TIP                             5
#define TIMER_DECK_KARDS_VIEW_CONTROLLER_SHOWING_SIMI_DELAY_VIEW            3.5
#define TIMER_FOR_INIT_INTERFACE                                            0.3
#define TIMER_SPLASH_SCREEN_ANIMATION                                       (0.1 * 30)

#define TIMER_MAIN_LOOP_BACKGROUND                                          10

#define DOUBLE_DISTANCE_GET_USER_LOCATION_METERS                            5.00
#define DOUBLE_DISTANCE_UNIT_MAX                                            10000.00
#define DOUBLE_DISTANCE_UNIT_MIN                                            100.00

#define FLOAT_DECELERATION_RATE_DEFAULT                                     0.7

#define MAXIMUM_SCALEABLE_RADIUS_METERS                                     5000000

#define RGBCOLOR(r, g, b)                                                   [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBACOLOR(r, g, b, a)                                               [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)/255.0f]
#define UIColorFromRGB(rgbValue)                                            [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define RELEASE_SAFE(p)                                                     { if (p) { [(p) release]; (p) = nil;  } }

#define LOG_RETAIN_COUNT(a)                                                 NSLog(@"LOG_RETAIN_COUNT: %i", [a retainCount]);
#define LOG(a)                                                              NSLog(@"LOG: %@", a);
#define FONT_APP_REGULAR                                                    @"Comfortaa"
#define FONT_APP_BOLD                                                       @"Comfortaa-Bold"
#define FONT_APP_THIN                                                       @"Comfortaa-Thin"


#define IS_IPAD                                                             [SupportFunction deviceIsIPad]
#define IS_IOS6_OR_HIGHER                                                   [SupportFunction deviceIsIos6OrHigher]

//**********USER_DEFAULT***********
#define STRING_USER_DEFAULT_USER_LOGIN_REMEBER_ME                           @"STRING_USER_DEFAULT_USER_LOGIN_REMEBER_ME"
#define STRING_USER_DEFAULT_USER_DATA_MANAGER                               @"STRING_USER_DEFAULT_USER_DATA_MANAGER"
#define STRING_USER_DEFAULT_USER_HEAVY_DATA_MANAGER                         @"STRING_USER_DEFAULT_USER_HEAVY_DATA_MANAGER"
#define STRING_USER_DEFAULT_FB_DATA_MANAGER                                 @"STRING_USER_DEFAULT_FB_DATA_MANAGER"
#define STRING_USER_DEFAULT_TW_DATA_MANAGER                                 @"STRING_USER_DEFAULT_TW_DATA_MANAGER"
#define STRING_USER_DEFAULT_VERSION_ID                                      [NSString stringWithFormat:@"STRING_USER_DEFAULT_VERSION_ID%@", STRING_REQUEST_ROOT]
#define STRING_USER_DEFAULT_VERSION_DATE                                    @"STRING_USER_DEFAULT_VERSION_DATE"
#define STRING_USER_DEFAULT_ORIENTATION                                     @"STRING_USER_DEFAULT_ORIENTATION"

//*********LIMIT-OFFSET***********
#define INT_DEFAULT_FIRST_PAGE                                              1
#define INT_DEFAULT_PAGE_SIZE                                               100
#define INT_DEFAULT_COUNTING_DOWN                                           5*60
#define INT_DEFAULT_COUNTING_UP                                             0

// Do not use these constant have prefix _. Use the other have same name below.
#define _HEIGHT_IPHONE                                                       480
#define _WIDTH_IPHONE                                                        320
#define _HEIGHT_IPHONE_5                                                     568
#define _WIDTH_IPHONE_5                                                      320
#define _HEIGHT_IPAD                                                         1024
#define _WIDTH_IPAD                                                          768

#define HEIGHT_IPHONE                                                       [SupportFunction getDeviceHeight]
#define WIDTH_IPHONE                                                        [SupportFunction getDeviceWidth]
#define HEIGHT_IPHONE_5                                                     [SupportFunction getDeviceHeight]
#define WIDTH_IPHONE_5                                                      [SupportFunction getDeviceWidth]
#define HEIGHT_IPAD                                                         [SupportFunction getDeviceHeight]
#define WIDTH_IPAD                                                          [SupportFunction getDeviceWidth]
#define HEIGHT_STATUS_BAR                                                   20
#define HEIGHT_TOOL_BAR                                                     44
#define HEIGHT_AD_BANNER                                                    50
#define HEIGHT_TAB_BAR                                                      49
#define HEIGHT_AD_BANNER_LANDSCAPE_IPHONE                                   32
#define HEIGHT_AD_BANNER_LANDSCAPE_IPAD                                     66

#define HEIGHT_IPHONE_KEYBOARD                                              216
#define HEIGHT_IPHONE_KEYBOARD_LANDSCAPE                                    162
#define HEIGHT_IPAD_KEYBOARD                                                264
#define HEIGHT_IPAD_KEYBOARD_LANDSCAPE                                      352

#define INT_RADIUS_SELECTED_KARD_AVATAR                                     3
#define INT_WIDTH_BORDER_SELECTED_KARD_AVATAR                               1
#define INT_RADIUS_SMALL_AVATAR                                             6
#define INT_WIDTH_BORDER_SMALL_AVATAR                                       1
#define INT_RADIUS_MEDIUM_AVATAR                                            11
#define INT_WIDTH_BORDER_MEDIUM_AVATAR                                      2
#define INT_RADIUS_LARGE_AVATAR                                             16
#define INT_WIDTH_BORDER_LARGE_AVATAR                                       3

#define FRAME(a,b,c,d)                                                      CGRectMake(a, b, c, d)

#define FRAME_MAIN(view)                                                    FRAME(0, view.frame.origin.y, view.frame.size.width, view.frame.size.height)
#define FRAME_RIGHT(view, dis)                                              FRAME(dis, view.frame.origin.y, view.frame.size.width, view.frame.size.height)
#define FRAME_LEFT(view, dis)                                               FRAME(-dis, view.frame.origin.y, view.frame.size.width, view.frame.size.height)
#define FRAME_TOP(view, dis)                                                FRAME(view.frame.origin.x, -dis, view.frame.size.width, view.frame.size.height)
#define FRAME_BOTTOM(view, dis)                                             FRAME(view.frame.origin.x, dis, view.frame.size.width, view.frame.size.height)

#define IMG_AVARTAR_DUMMY                                                   [UIImage imageNamed:@"img_bg_avatar_dummy.png"]

// ************ ALERT **************
#define STRING_ALERT_RETRY                                                  @"Retry"
#define STRING_ALERT_CANCEL                                                 @"Cancel"
#define STRING_ALERT_OK                                                     @"OK"
#define STRING_ALERT_DISMISS                                                @"Dismiss"
#define STRING_ALERT_YES                                                    @"Yes"
#define STRING_ALERT_NO                                                     @"No"
#define STRING_ALERT_CANCEL                                                 @"Cancel"
#define STRING_ALERT_DELETE                                                 @"Delete"

#define STRING_ALERT_TITLE_WARNING                                          @"Warning"
#define STRING_ALERT_TITLE_ALERT                                            @"Alert"
#define STRING_ALERT_TITLE_ANNOUNCERMENT                                    @"Announcement"
#define STRING_ALERT_TITLE_ERROR                                            @"Error"
#define STRING_ALERT_TITLE_SORRY                                            @"Sorry"
#define STRING_ALERT_TITLE_SUCCESS                                          @"Success"
#define STRING_ALERT_TITLE_FAILURE                                          @"Failure"

#define STRING_ALERT_MESSAGE_CAMERA_PHOTO_NOT_SUPPORTED                     @"This device is not supported for Camera or Photo"
#define STRING_ALERT_MESSAGE_TURN_ON_LOCATION_SERVICE                       @"Please turn on Location Service\n to use this app"

#define STRING_COMPARED_NSARRAY_M                                           @"__NSArrayM"
#define STRING_COMPARED_NSCFSTRING                                          @"__NSCFString"
#define STRING_COMPARED_NSCFCONSTANTSTRING                                  @"__NSCFConstantString"
#define STRING_COMPARED_NSCONCRTEMUTABLEDATA                                @"NSConcreteMutableData"

// ************* IMAGE **************
#define STRING_ID_FB_FORMATTER(id)                                          [NSString stringWithFormat:@"fb_%@", id]
#define STRING_ID_TW_FORMATTER(id)                                          [NSString stringWithFormat:@"tw_%@", id]

// ************ LOCATION ************
#define STRING_LOCATION_LATITUDE_DEFAULT                                    @"+10.773000"
#define STRING_LOCATION_LONGTITUDE_DEFAULT                                  @"106.677700"

// ************* SOUND **************
#define STRING_SOUND_NOTIFICATION                                           @"sound_tri_tone.mp3"

typedef enum
{
    ENUM_APP_VIEW_CONTROLLER_SCREEN_TYPE_INVALID,
    ENUM_APP_VIEW_CONTROLLER_SCREEN_TYPE_HOME_SCREEN,
    ENUM_APP_VIEW_CONTROLLER_SCREEN_TYPE_KARDS_VIEW_CONTROLLER,
    ENUM_APP_VIEW_CONTROLLER_SCREEN_TYPE_DECK_VIEW_CONTROLLER,
    ENUM_APP_VIEW_CONTROLLER_SCREEN_TYPE_SIMPLE_KARD_VIEW_CONTROLLER,
    ENUM_APP_VIEW_CONTROLLER_SCREEN_TYPE_KARD_BUILDER_VIEW_CONTROLLER,
    
    ENUM_APP_VIEW_CONTROLLER_SCREEN_TYPE_KONNECT_VIEW_CONTROLLER,
    
    ENUM_APP_VIEW_CONTROLLER_SCREEN_TYPE_DEALS_VIEW_CONTROLLER,
    
    ENUM_APP_VIEW_CONTROLLER_SCREEN_TYPE_NEWS_VIEW_CONTROLLER
}ENUM_APP_VIEW_CONTROLLER_SCREEN_TYPE;

typedef enum
{
    ENUM_APP_VIEW_CONTROLLER_STEP_INVALID,
    ENUM_APP_VIEW_CONTROLLER_STEP_UPDATE_USER_LOCATION,
    ENUM_APP_VIEW_CONTROLLER_STEP_GET_USER_PROFILE,
    ENUM_APP_VIEW_CONTROLLER_STEP_UPDATE_USER_ONLINE_STATUS,
    ENUM_APP_VIEW_CONTROLLER_STEP_END
}ENUM_APP_VIEW_CONTROLLER_STEP;

typedef enum
{
    ENUM_API_REQUESTER_STEP_INVALID,
    ENUM_API_REQUESTER_STEP_REQUEST,
    ENUM_API_REQUESTER_STEP_REQUEST_WAITING,
    ENUM_API_REQUESTER_STEP_FAILED,
    ENUM_API_REQUESTER_STEP_FINISHED,
    ENUM_API_REQUESTER_STEP_TIMEOUT,
    ENUM_API_REQUESTER_STEP_ALERT_SHOWING,
    ENUM_API_REQUESTER_STEP_END
}ENUM_API_REQUESTER_STEP;

typedef enum
{
    ENUM_API_REQUEST_TYPE_INVALID,
    
    ENUM_API_REQUEST_TYPE_USER_FB_GET_PROFILE,
    ENUM_API_REQUEST_TYPE_USER_TW_GET_PROFILE,
    ENUM_API_REQUEST_TYPE_USER_GET_ALL,
    ENUM_API_REQUEST_TYPE_USER_REGISTER,
    ENUM_API_REQUEST_TYPE_USER_LOGIN,
    ENUM_API_REQUEST_TYPE_USER_LOGOUT,
	ENUM_API_REQUEST_TYPE_USER_LOGIN_WITH_FB_TW,
    ENUM_API_REQUEST_TYPE_USER_UPDATE_LOCATION,
    ENUM_API_REQUEST_TYPE_USER_GET_PROFILE,
    ENUM_API_REQUEST_TYPE_USER_GET_BANNER_ADS,
    ENUM_API_REQUEST_TYPE_USER_UPDATE_ONLINE_STATUS,
    ENUM_API_REQUEST_TYPE_USER_FULL_NAME,
    ENUM_API_REQUEST_TYPE_USER_RECOVER_PASSWORD,
    ENUM_API_REQUEST_TYPE_USER_CHECK_INVATION_CODE,
    ENUM_API_REQUEST_TYPE_USER_FORGET_PASSWORD,
    
    ENUM_API_REQUEST_TYPE_USER_UPDATE_DEVICE_TOKEN,
    ENUM_API_REQUEST_TYPE_USER_UPDATE_DEVICE_UDID,
    ENUM_API_REQUEST_TYPE_USER_UPDATE_USER_INFO,
    ENUM_API_REQUEST_TYPE_USER_UPDATE_NOTIFICATION_CENTER,
    
    ENUM_API_REQUEST_TYPE_USER_UPDATE_COUNTRY_CODE,
    
    // ACTIONS
    ENUM_API_REQUEST_TYPE_ACTIONS_ENTER_FOREGROUND_APP,
    ENUM_API_REQUEST_TYPE_ACTIONS_CONTACT_BY_EMAIL_01,
    ENUM_API_REQUEST_TYPE_ACTIONS_OPEN_URL_01,
    ENUM_API_REQUEST_TYPE_ACTIONS_CALL_PHONE_01,
    ENUM_API_REQUEST_TYPE_ACTIONS_CALL_PHONE_02,
    ENUM_API_REQUEST_TYPE_ACTIONS_VIEW_ROOM_INFO,
    
    // PHONGDEP
    ENUM_API_REQUEST_TYPE_PHONGDEP_GET_ROOMS,
    ENUM_API_REQUEST_TYPE_PHONGDEP_GET_HOUSES,
    ENUM_API_REQUEST_TYPE_PHONGDEP_GET_ROOM_DETAIL,
    ENUM_API_REQUEST_TYPE_PHONGDEP_GET_HOUSE_DETAIL,
    
    // FACEBOOK
    ENUM_API_REQUEST_TYPE_FB_GET_FRIENDS,
    ENUM_API_REQUEST_TYPE_FB_POST_TO_MY_WALL,
    ENUM_API_REQUEST_TYPE_FB_POST_TO_FRIEND_WALL,
    
    // TWITTER
    ENUM_API_REQUEST_TYPE_TW_GET_FRIENDS,
    ENUM_API_REQUEST_TYPE_TW_POST_TO_MY_WALL,
    ENUM_API_REQUEST_TYPE_TW_POST_TO_FRIEND_WALL,
    
    // NUM
    ENUM_API_REQUEST_TYPE_FEEDS_CHECK_TOTAL_NUMBER
}ENUM_API_REQUEST_TYPE;

typedef enum
{
    ENUM_APP_BACKGROUND_STATE_INVALID,
    ENUM_APP_BACKGROUND_STATE_DID_ENTER,
    ENUM_APP_BACKGROUND_STATE_TIMER_ACTIVE_BEFORE_ENTERING_FOREGROUND,
    ENUM_APP_BACKGROUND_STATE_ENTER_FOREGROUND,
    ENUM_APP_BACKGROUND_STATE_TIMER_ACTIVE_AFTER_ENTERING_FOREGROUND
}ENUM_APP_BACKGROUND_STATE;

typedef enum {
    ENUM_KEYBOARD_STATUS_INVALID,
    ENUM_KEYBOARD_STATUS_FORCE_HIDE,
    ENUM_KEYBOARD_STATUS_RETURN,
    ENUM_KEYBOARD_STATUS_RETURN_AND_DID_BEGIN_EDITING,
    ENUM_KEYBOARD_STATUS_DID_END_EDITING,
    ENUM_KEYBOARD_STATUS_DID_BEGIN_EDITING
}ENUM_KEYBOARD_STATUS;

typedef enum
{
    ENUM_CITY_TABLE_BY_NAME,
    ENUM_CITY_TABLE_BY_DISTANCE,
}ENUM_CITY_TABLE;

@protocol AppViewControllerProtocol <NSObject>
@optional
- (void)update;
- (void)updateOnlyForForeground;
@end

typedef enum {
    enumRemoveNotificationType_Invalid = 0,
    enumRemoveNotificationType_SystemUpgrade = 1
}enumRemoveNotificationType;

// PHONGDEP
#define STRING_ADDRESS_FORMAT(address, district, city)                      [NSString stringWithFormat:@"Địa chỉ: %@, Quận %@, Tỉnh/TP %@.", address, district, city];
#define STRING_REMAINING_DAY_FORMAT(remaining_day)                          [NSString stringWithFormat:@"còn %i ngày", remaining_day]

#define IMG_BANNER_HEADER                                                   [UIImage imageNamed:@"img_banner_header_444_64"]
#define IMG_BG_MENU_BAR                                                     [UIImage imageNamed:@"img_bg_menubar_20_90"]
#define IMG_ICO_LOGO_HEADER                                                 [UIImage imageNamed:@"ico_logo_header_60_60"]
#define IMG_AVAILABILITY                                                    [UIImage imageNamed:@"img_available_room_now_100_100"]
#define IMG_REMAINING_DAY                                                   [UIImage imageNamed:@"img_available_room_n_day_100_100"]

#define IMG_ICO_CONTACT                                                     [UIImage imageNamed:@"ico_contact_40_40"]
#define IMG_ICO_ROOM                                                        [UIImage imageNamed:@"ico_room_40_40"]
#define IMG_ICO_HOME                                                        [UIImage imageNamed:@"ico_home_40_40"]
#define IMG_ICO_MENU                                                        [UIImage imageNamed:@"ico_menu_40_40"]
#define IMG_ICO_LOCATION                                                    [UIImage imageNamed:@"ico_location_40_40"]
#define IMG_ICO_MAP_CURRENT_LOCATION                                        [UIImage imageNamed:@"ico_map_current_location_100_100"]
#define IMG_ICO_MAP_GET_DIRECTIONS                                          [UIImage imageNamed:@"ico_map_get_directions_100_100"]
